<template>
  <div class="m-view-matterApplyMenu m-window">
    <div class="m-module" v-for="(item, index) in menu" :key="index">
      <div class="m-title">{{ item.title }}</div>
      <ul>
        <li
          v-for="(list, serial) in item.list"
          :key="serial"
          @click="addTab(list)"
          :class="{ 'm-completed': list.completed }"
        >
          <i :class="'iconfont icon-' + list.name"></i>
          <span>{{ list.cName }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import utils from "@/public/utils";
import authorize from "@/public/authorize";

export default {
   data(){
       return{
           menu: [
        {
          title: "物料申购管理",
          list: [],
        },
      ],
       }
   },
   props: {
		addTab: {
			type: Function
		}
	},
    methods:{
        getMenuDetails () {
			let parentId = utils.getMenuId("menuId"); // 菜单ID
			let activeMenu = [];
			authorize.getMenuAuth(parentId).then((res) => {
                
				if (Array.isArray(res) && res.length > 0) {
					this.menu.forEach((menu, index) => {
						activeMenu.push({
							title: menu.title,
							list: [],
						});
						res.forEach((item) => {
                            activeMenu[index].list.push({
                                name: item.code,
                                cName: item.name,
                                completed: true,
                            });
						});
					});
					this.menu = activeMenu;
          console.log(this.menu,'物流申购')
                  
				}
			});
		}
    },
    beforeMount () {
		this.getMenuDetails();
	}
}
</script>
